import requests
from bs4 import BeautifulSoup


DEBUG=True#False#
def debug_print(*p):
    if DEBUG:
        print(*p)

def htm_info():
    lastTimes=[]
    base_url = 'http://haifir.com/'
    #user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0'
    user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0'
    headers = {'User-Agent': user_agent}

    res = requests.get(base_url, headers=headers)
    # print(res.text)
    # print(res.status_code) #打印出状态，如是不是200，说明有问题
    soup = BeautifulSoup(res.text, 'html.parser')
    seconds = soup.findAll("b", attrs={"id": 'seconds'})
    for secondsTime in seconds:
        debug_print("")

    minutes = soup.findAll("b", attrs={"id": 'minutes'})
    for minutesTime in minutes:
        debug_print("")
    #debug_print(minutesTime.string + ":" + secondsTime.string)
    whatTime = soup.findAll("i", attrs={"id": "period"})
    for i in whatTime:
        debug_print('最新的期数是', i.string)
    times =soup.findAll("td")
    for i in range(3):
        debug_print("最后一期的数据",times[i].string)
        lastTimes.append(times[i].string)


    return int(minutesTime.string),int(secondsTime.string),lastTimes